﻿using System.Collections.Generic;

using SharpArch.Core;
using SharpArch.Core.PersistenceSupport;
using SharpArch.Data.NHibernate;
using SharpArch.Testing.NUnit;
using SharpArch.Testing.NUnit.NHibernate;

using NUnit.Framework;

using Quiziqal.Domain;
using Quiziqal.Persistence;

namespace Quiziqal.Specifications.Persistence
{
    public abstract class PersistenceTestBase : RepositoryBehaviorSpecificationTestsBase
    {
        protected User CreatePersistedUser(string username)
        {
            User user = new User(username);
            new UserRepository().SaveOrUpdate(user);
            FlushSessionAndEvict(user);
            return user;
        }

        protected Quiz CreatePersistedQuiz(string name, User owner)
        {
            Quiz quiz = new Quiz(owner) { Name = name };
            new QuizRepository().SaveOrUpdate(quiz);
            FlushSessionAndEvict(quiz);
            return quiz;
        }
    }
}
